﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEnergyConsumptionRecord" @search="getTableDataEnergyConsumptionRecord">
      <el-row>
        
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="UploadTime_FormItem" prop="UploadTime" label="上传时间">
            <el-date-picker v-model="searchDataEnergyConsumptionRecord.UploadTime" clearable></el-date-picker>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="stationCode_FormItem" prop="stationCode" label="工位号">
            <el-input v-model="searchDataEnergyConsumptionRecord.stationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="machineCode_FormItem" prop="machineCode" label="设备编号">
            <el-input v-model="searchDataEnergyConsumptionRecord.machineCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Airpressure_FormItem" prop="Airpressure" label="压力">
            <el-input v-model="searchDataEnergyConsumptionRecord.Airpressure" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Flow_FormItem" prop="Flow" label="累计流量">
            <el-input v-model="searchDataEnergyConsumptionRecord.Flow" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Energy_FormItem" prop="Energy" label="累计电能">
            <el-input v-model="searchDataEnergyConsumptionRecord.Energy" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="VoltageA_FormItem" prop="VoltageA" label="A相电压">
            <el-input v-model="searchDataEnergyConsumptionRecord.VoltageA" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="VoltageB_FormItem" prop="VoltageB" label="B相电压">
            <el-input v-model="searchDataEnergyConsumptionRecord.VoltageB" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="VoltageC_FormItem" prop="VoltageC" label="C相电压">
            <el-input v-model="searchDataEnergyConsumptionRecord.VoltageC" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ElectricityA_FormItem" prop="ElectricityA" label="A相电流">
            <el-input v-model="searchDataEnergyConsumptionRecord.ElectricityA" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ElectricityB_FormItem" prop="ElectricityB" label="B相电流">
            <el-input v-model="searchDataEnergyConsumptionRecord.ElectricityB" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ElectricityC_FormItem" prop="ElectricityC" label="C相电流">
            <el-input v-model="searchDataEnergyConsumptionRecord.ElectricityC" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Time_FormItem" prop="Time" label="采集时间">
            <el-input v-model="searchDataEnergyConsumptionRecord.Time" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="acquisitionInterval_FormItem" prop="acquisitionInterval" label="采集时间间隔">
            <el-input v-model="searchDataEnergyConsumptionRecord.acquisitionInterval" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="machineStatus_FormItem" prop="machineStatus" label="设备状态">
            <el-input v-model="searchDataEnergyConsumptionRecord.machineStatus" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="uploadflag_FormItem" prop="uploadflag" label="上传标识">
            <el-select v-model="searchDataEnergyConsumptionRecord.uploadflag" clearable>
                <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
                <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
                </el-select>
        </el-form-item>
    </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EnergyConsumptionRecord/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EnergyConsumptionRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EnergyConsumptionRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EnergyConsumptionRecord/EnergyConsumptionRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEnergyConsumptionRecord" v-bind="tableDataEnergyConsumptionRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
          <el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/EnergyConsumptionRecord/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
					<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/EnergyConsumptionRecord/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
					<el-popconfirm :title="$t('message._system.common.vm.deletetip')"  @confirm="onDelete(scope.row)">
						<template #reference>
							<el-button text type="danger" v-auth="'/api/EnergyConsumptionRecord/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
						</template>
					</el-popconfirm>
        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="能耗记录;true;TyMES.Controllers;EnergyConsumptionRecord">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { EnergyConsumptionRecordApi } from '/@/api/record/EnergyConsumptionRecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEnergyConsumptionRecord = reactive({
    
});

const searchDataEnergyConsumptionRecord = ref({
    			UploadTime: null,
			stationCode: null,
			machineCode: null,
			Airpressure: null,
			Flow: null,
			Energy: null,
			VoltageA: null,
			VoltageB: null,
			VoltageC: null,
			ElectricityA: null,
			ElectricityB: null,
			ElectricityC: null,
			Time: null,
			acquisitionInterval: null,
			machineStatus: null,
			uploadflag: null,

});

// 定义变量内容
const tableRefEnergyConsumptionRecord = ref();
const tableDataEnergyConsumptionRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
  
        {title:'上传时间',key: 'UploadTime',type: 'text',isCheck: true},
        {title:'工位号',key: 'stationCode',type: 'text',isCheck: true},
        {title:'设备编号',key: 'machineCode',type: 'text',isCheck: true},
        {title:'压力',key: 'Airpressure',type: 'text',isCheck: true},
        {title:'累计流量',key: 'Flow',type: 'text',isCheck: true},
        {title:'累计电能',key: 'Energy',type: 'text',isCheck: true},
        {title:'A相电压',key: 'VoltageA',type: 'text',isCheck: true},
        {title:'B相电压',key: 'VoltageB',type: 'text',isCheck: true},
        {title:'C相电压',key: 'VoltageC',type: 'text',isCheck: true},
        {title:'A相电流',key: 'ElectricityA',type: 'text',isCheck: true},
        {title:'B相电流',key: 'ElectricityB',type: 'text',isCheck: true},
        {title:'C相电流',key: 'ElectricityC',type: 'text',isCheck: true},
        {title:'采集时间',key: 'Time',type: 'text',isCheck: true},
        {title:'单位',key: 'Unit',type: 'text',isCheck: true},
        {title:'采集时间间隔',key: 'acquisitionInterval',type: 'text',isCheck: true},
        {title:'设备状态',key: 'machineStatus',type: 'text',isCheck: true},
        {title:'上传标识',key: 'uploadflag',type: 'switch',isCheck: true},
	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEnergyConsumptionRecord = () => {
    tableRefEnergyConsumptionRecord.value.doSearch(EnergyConsumptionRecordApi().search, searchDataEnergyConsumptionRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableDataEnergyConsumptionRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableDataEnergyConsumptionRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableDataEnergyConsumptionRecord)
};

// 删除
const onDelete = (row: any) => {
    EnergyConsumptionRecordApi().delete([row.ID]).then(() => { getTableDataEnergyConsumptionRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEnergyConsumptionRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      EnergyConsumptionRecordApi().delete(selectedids).then(() => { getTableDataEnergyConsumptionRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableDataEnergyConsumptionRecord)
};

const onExport = () => {
	const selected = tableRefEnergyConsumptionRecord.value.getSelectedRows();
	if (selected.length > 0) {
		EnergyConsumptionRecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		EnergyConsumptionRecordApi().export({});
	}
};

// 页面加载时
onMounted(() => {
     
        getTableDataEnergyConsumptionRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

